package com.adolph.netty.nettydemo;

import com.adolph.netty.dto.MessageObj;
import com.alibaba.fastjson.JSON;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

/**
 * 〈功能概述〉<br>
 *
 * @author: wangxiangjun
 * @date: 2020-10-13 15:53
 */

public class StringToObjDecoder extends MessageToMessageDecoder <String>{
    @Override
    protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
        MessageObj messageObj = JSON.parseObject(msg,MessageObj.class);
        out.add(messageObj);
    }
}
